<html>
<head>
	<title>Excersise 5</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
	var numbers = new Array(5, 7, 4, 5, 6, 8, 11, 6, 7, 3);
	var minElement = 1;
	var tempElement;
	var minIndex = 0;
	jsConsole.writeLine("unsorted array: ");
	for (k=0;k<numbers.length;k++)
	{
		jsConsole.write(numbers[k] + " ");
	}
	jsConsole.writeLine();
	for (i = 0;i < numbers.length;i++)
	{	
		minElement = numbers[i];
		for (j = i; j < numbers.length;j++)
		{
			if (numbers[j] < minElement)
			{
				minElement = numbers[j];
				minIndex = j;
			}
			if (numbers[i] != minElement)
			{
			    numbers[i] = (numbers[minIndex] + numbers[i]) - (numbers[minIndex] = numbers[i]);
			}
		}
	}
	jsConsole.writeLine("sorted array: ");
	for (k=0;k<numbers.length;k++)
	{
		jsConsole.write(numbers[k] + " ");
	}
	</script>
</body>
</html>
